package com.jingogo.controller;

import com.jingogo.common.Result;
import com.jingogo.entity.GoldPrice;
import com.jingogo.service.GoldPriceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/price")
@Tag(name = "金价管理", description = "实时金价与历史价格接口")
public class PriceController {
    @Autowired
    private GoldPriceService goldPriceService;

    @GetMapping("/realtime")
    @Operation(summary = "实时金价", description = "获取实时金价")
    public Result<List<GoldPrice>> getRealtimePrice() {
        return Result.success(goldPriceService.getRealtimePrice());
    }

    @GetMapping("/history")
    @Operation(summary = "历史金价", description = "获取历史金价")
    public Result<List<GoldPrice>> getHistoryPrice(@RequestParam Date startDate, @RequestParam Date endDate) {
        return Result.success(goldPriceService.getHistoryPrice(startDate, endDate));
    }
} 